<script setup lang="ts">
import { ref } from "vue";
import { updateRoles } from "@/service/api";


const visible = ref(false)

const defaultFrom = {
    name: '',
    description: '',
    sort: 0
}
// 表单数据
const fromModel = ref({ ...defaultFrom });
const open = (row: any) => {
    visible.value = true
    fromModel.value = row
}
const updateRole = async () => {
    await updateRoles(fromModel.value).then(res => {
        ElMessage.success('修改成功！！！')
        visible.value = false
        console.log(res);
    }).catch(err => {
        console.log(err);
    })
}
defineExpose({
    open
})
</script>


<template>
    <el-dialog v-model="visible" :close-on-click-modal="false" :close-on-press-escape="false">
        <el-form ref="dataFormRef" label-width="120px">
            <el-form-item label="角色名称" prop="name">
                <el-input placeholder="角色名称" v-model="fromModel.name"></el-input>
            </el-form-item>
            <el-form-item label="角色标识" prop="description">
                <el-input placeholder="角色标识" v-model="fromModel.description"></el-input>
            </el-form-item>
            <el-form-item label="排序" prop="sort">
                <el-input-number v-model="fromModel.sort" class="mx-4" :min="0" :max="10" controls-position="right" />
            </el-form-item>
        </el-form>
        <template #footer>
            <span>
                <el-button @click="visible = false" style="margin-right: 10px;">取消</el-button>
                <el-button type="primary" @click="updateRole">确定</el-button>
            </span>
        </template>
    </el-dialog>
</template>

<style scoped lang="less"></style>